# @Author: TonghuiWu
# @Date:   2018-11-23 23:03:54
# @Last Modified by:   TonghuiWu
# @Last Modified time: 2018-11-23 23:48:54
# @E-mail: wutonghui22@163.com

import xadmin

from .models import Course, Lesson, Video, CourseResource


class CourseAdmin(object):
    """
    '课程'表在后台管理中的管理设置
    """
    list_display = ['name','desc', 'degree', 'learn_times', 'students', 'fav_nums', 'image', 'click_nums', 'add_time']
    search_fields = ['name','desc', 'degree', 'learn_times', 'students', 'fav_nums', 'image', 'click_nums']
    list_filter = ['name','desc', 'degree', 'learn_times', 'students', 'fav_nums', 'image', 'click_nums', 'add_time']

class LessonAdmin(object):
    """
    '章节'表在后台管理中的管理设置
    """
    list_display = ['course', 'name', 'add_time']
    search_fields = ['course', 'name']
    list_filter = ['course__name', 'name', 'add_time']

class VideoAdmin(object):
    """
    '视频'表在后台管理中的管理设置
    """
    list_display = ['lesson', 'name', 'add_time']
    search_fields = ['lesson', 'name']
    list_filter = ['lesson__name', 'name', 'add_time']

class CourseResourceAdmin(object):
    """
    '课程资源'表在后台管理中的管理设置
    """
    list_display = ['course', 'download', 'add_time']
    search_fields = ['course', 'download']
    list_filter = ['course__name', 'download', 'add_time']


xadmin.site.register(Course, CourseAdmin)
xadmin.site.register(Lesson, LessonAdmin)
xadmin.site.register(Video, VideoAdmin)
xadmin.site.register(CourseResource, CourseResourceAdmin)